using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.skill
{
[System.Serializable]
public  class SkillLevel :   cfg.EditorReadWriter 
 {

    public int needExp ;
     public int needMasteryLv ;
     public string skillDes  = "";
     public System.Collections.Generic.List<cfg.skill.SkillLevelAttr> baseAttrs  = new System.Collections.Generic.List<cfg.skill.SkillLevelAttr>();
     public System.Collections.Generic.List<cfg.fight.AttrValue> collectAttrs  = new System.Collections.Generic.List<cfg.fight.AttrValue>();
     


    public const int TYPE_ID = 382052314;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(5);
        os.WriteSize(Tag.INT | (1 << Tag.TAG_SHIFT));  os.WriteInt(needExp);  
         os.WriteSize(Tag.INT | (2 << Tag.TAG_SHIFT));  os.WriteInt(needMasteryLv);  
         os.WriteSize(Tag.STRING | (3 << Tag.TAG_SHIFT));  os.WriteString(skillDes);  
         os.WriteSize(Tag.LIST | (4 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_skill_SkillLevelAttr(baseAttrs,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         os.WriteSize(Tag.LIST | (5 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_fight_AttrValue(collectAttrs,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.INT | (1 << Tag.TAG_SHIFT)):   needExp = os.ReadInt(); break;  
             case (Tag.INT | (2 << Tag.TAG_SHIFT)):   needMasteryLv = os.ReadInt(); break;  
             case (Tag.STRING | (3 << Tag.TAG_SHIFT)):   skillDes = os.ReadString(); break;  
             case (Tag.LIST | (4 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); baseAttrs = cfg.Extensions.unmarshal_compatible_list_cfg_skill_SkillLevelAttr(os); os = _oldOs; break; }   
             case (Tag.LIST | (5 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); collectAttrs = cfg.Extensions.unmarshal_compatible_list_cfg_fight_AttrValue(os); os = _oldOs; break; }   
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "SkillLevel");
        ele.WriteStartElement("needExp"); ele.WriteAttributeString("id", "1"); ele.WriteInt(needExp); ele.WriteEndElement();
         ele.WriteStartElement("needMasteryLv"); ele.WriteAttributeString("id", "2"); ele.WriteInt(needMasteryLv); ele.WriteEndElement();
         ele.WriteStartElement("skillDes"); ele.WriteAttributeString("id", "3"); ele.WriteString2(skillDes); ele.WriteEndElement();
         ele.WriteStartElement("baseAttrs"); ele.WriteAttributeString("id", "4"); cfg.Extensions.xml_marshal_list_cfg_skill_SkillLevelAttr(baseAttrs,ele); ele.WriteEndElement();
         ele.WriteStartElement("collectAttrs"); ele.WriteAttributeString("id", "5"); cfg.Extensions.xml_marshal_list_cfg_fight_AttrValue(collectAttrs,ele); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  needExp = ele.ReadInt(); break; 
                 case 2:  needMasteryLv = ele.ReadInt(); break; 
                 case 3:  skillDes = ele.ReadString2(); break; 
                 case 4:  baseAttrs = cfg.Extensions.xml_unmarshal_list_cfg_skill_SkillLevelAttr(ele); break; 
                 case 5:  collectAttrs = cfg.Extensions.xml_unmarshal_list_cfg_fight_AttrValue(ele); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "need_exp":  needExp = ele.ReadInt(); break; 
                 case "need_mastery_lv":  needMasteryLv = ele.ReadInt(); break; 
                 case "skill_des":  skillDes = ele.ReadString2(); break; 
                 case "base_attrs":  baseAttrs = cfg.Extensions.xml_unmarshal_list_cfg_skill_SkillLevelAttr(ele); break; 
                 case "collect_attrs":  collectAttrs = cfg.Extensions.xml_unmarshal_list_cfg_fight_AttrValue(ele); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
